package pers.cz.javacvdemo.redis.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import pers.cz.javacvdemo.redis.RedisService;

/**
 * @author yiyi.su
 * @version 1.0.0
 * @description RedisConfig
 * @createTime 2022/8/15
 */
@Configuration(enforceUniqueMethods = false)
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
public class RedisConfig {

	@Bean
	@ConditionalOnMissingBean({RedisService.class})
	public RedisService redisService(StringRedisTemplate redisTemplate) {
		return new RedisService(redisTemplate);
	}
}
